package weka.roleminers;

import java.util.ArrayList;
import java.util.List;

public class Role {

	private List<String> permitions;
	private int users = 1;
	private List<Role> contributors;
	private boolean contributor = false;

	public Role(List<String> permitions) {
		this.permitions = permitions;
		this.contributors = new ArrayList<Role>();
	}

	public Role(List<String> permitions, int i) {
		this.permitions = permitions;
		this.contributors = new ArrayList<Role>();
		this.users = i;
	}

	public List<String> getPermitions() {
		return permitions;
	}

	public void resetUsers() {
		users = 0;
	}

	public void incrementUsers() {
		this.users++;
	}

	public void incrementUsers(int i) {
		this.users += i;
	}

	public int users() {
		return users;
	}

	public boolean contains(Role iRole) {
		for (String permition : iRole.getPermitions()) {
			if (!this.permitions.contains(permition)) {
				return false;
			}
		}
		return true;
	}

	public void addContributor(Role role) {
		this.contributors.add(role);
		role.contributed();
	}

	public List<Role> getContributors() {
		return contributors;
	}

	public boolean isContributor() {
		return contributor;
	}

	public void contributed() {
		contributor = true;
	}
}
